home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!tsys.demon.co.uk
- From: Tom Wheeley <tomw@tsys.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: Can anyone HELP with variable delaration? Please?
- Date: Sun, 07 Apr 96 01:42:57 GMT
- Organization: City Zen FM
- Message-ID: <828841377snz@tsys.demon.co.uk>
- References: <4jt07b$dul@news.us.net> <3162119a.43634755@news.ucs.ubc.ca> <4juf2kINNe9v@keats.ugrad.cs.ubc.ca> <3162de71.18703379@news.ucs.ubc.ca>
- Reply-To: tomw@tsys.demon.co.uk
- X-NNTP-Posting-Host: tsys.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.30
- X-Sig-By: Tomsystems Quote v1.2. (c)1996 Tom Wheeley, tomw@tsys.demon.co.uk
- X-Mail2News-Path: tsys.demon.co.uk
-
- In article <3162de71.18703379@news.ucs.ubc.ca>
- jamesdf@unixg.ubc.ca "James Fairweather" writes:
-
- > >Any variable can be declared constant, including strings:
- > >
- > > const char * const str = "Foo";
- > >
- > >Or do you mean literal constants?
- > >
- > I'm not sure what the difference is. I thought the keyword "const"
- > was just for the compiler. If you tried to modify the variable
- > declared const, the compiler would complain. Does it do something
- > else with the variable if you declare it const?
- >
- > >In what way are integers a suitable alternative representation for string data?> >--
- > I guess I was being too extreme. It's just that in high school, when
- > we were coding with Pascal, we were encouraged to use strings
- > whereever possible. Don't ask me why; it never occurred to me to ask
- > at the time. And sometimes when I read other people's code,
- > espeically people who are used to Pascal, I often see them using
- > strings in an if...else situation. In these cases, a well-name
- > #defined constant works better, because you can use switch and the
- > comparison is faster.
-
- I must say that that sounds appalling! I would never use a string like that.
- (Although I would be interested if someone could point out a useful time for
- this).
- In Pascal, (well, Borland Pascal for sure) you would use enumerated types.
-
- It is true that the Pascal `string' data type does encourage you to use
- more strrings than in C. C actually makes you feel a bit guilty, as you
- have to do all that malloc()ing and strcmp() and strcpy() to do things, rather
- than a seemingly far less significant `:=', `=' or var myvar: string;
-
- .splitbung
- --
- * TQ 1.0 * The 'Just So Quotes'.
- "This is a one line proof...if we start sufficiently far to the left."
- -- peter@cbmvax.cbm.commodore.com
-